package com.sandking.tools;

/**
 * @UserName : SandKing
 * @DataTime : 2013-6-5 上午10:48:40
 * @Description ：Please describe this document
 */
public class SK_Vector {
	private double x;
	private double y;
	private double z;

	public SK_Vector(double x, double y) {
		super();
		this.x = x;
		this.y = y;
	}

	public SK_Vector(double x, double y, double z) {
		super();
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getZ() {
		return z;
	}

	public void setZ(double z) {
		this.z = z;
	}

	/**
	 * 计算2个点的距离
	 * 
	 * @param vector
	 * @return
	 */
	public double distance(SK_Vector vector) {
		double x = Math.abs(this.x - vector.x);
		double y = Math.abs(this.y - vector.y);
		double sum = Math.pow(x, 2) + Math.pow(y, 2);
		return Math.sqrt(sum);
	}

	/**
	 * 是否在同一坐标
	 * 
	 * @param vector
	 * @return
	 */
	public boolean equals(SK_Vector vector) {
		if (vector == null)
			return false;
		if (this.x == vector.x && this.y == vector.y && this.z == vector.z) {
			return true;
		} else {
			return false;
		}
	}
}
